Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
setprototypeof
Advanced tools
The setprototypeof package is a simple module that allows you to set the prototype of an object, which can be useful for creating a chain of prototypes (i.e., inheritance) or for changing an object's prototype on-the-fly. It is a polyfill for the official ECMAScript 2015 (ES6) Object.setPrototypeOf method.
Setting the prototype of an object
This feature allows you to set the prototype of an object to another object. After setting the prototype, the object will have access to the properties and methods of the new prototype.
{"object": {"prop": "value"}, "prototype": {"newProp": "newValue"}}
The object-assign package is used to copy the values of all enumerable own properties from one or more source objects to a target object. It is similar to setprototypeof in that it is used for manipulating objects, but it does not change the prototype chain.
Lodash's assign function is similar to object-assign and is used to assign own enumerable properties of source objects to the destination object. Like object-assign, it does not deal with the prototype chain but rather with copying properties.
The util package is a collection of utilities originally for the Node.js standard library. It includes util.inherits, which is a method that allows you to set the prototype of a constructor to an object, creating a prototype chain similar to what setprototypeof does, but specifically for constructor functions.
Object.setPrototypeOf
A simple cross platform implementation to set the prototype of an instianted object. Supports all modern browsers and at least back to IE8.
$ npm install --save setprototypeof
var setPrototypeOf = require('setprototypeof')
var obj = {}
setPrototypeOf(obj, {
foo: function () {
return 'bar'
}
})
obj.foo() // bar
TypeScript is also supported:
import setPrototypeOf from 'setprototypeof'
FAQs
A small polyfill for Object.setprototypeof
The npm package setprototypeof receives a total of 43,646,984 weekly downloads. As such, setprototypeof popularity was classified as popular.
We found that setprototypeof demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.